<?php
/**
 * Created by PhpStorm.
 * User: td
 * Date: 15/1/12
 * Time: 下午11:14
 */

namespace Home\Controller;
use Think\Controller;

class FetcherController extends Controller {

    //接活首页－未登录
    public function index(){
        //loginStatus();
        $this->display();
    }

    //接活首页－登陆
    public function indexLogin(){
        if(isset($_SESSION['loginUser'])){
            $this->display("Fetcher/indexLogin");
        }else{
            $this->error('请登陆系统',U('Login/index'));
        }
    }

    //接活首页动态信息获取-未登录
    public function fetcherIndex(){
        $jobs = $_GET['jobs'];
        $duration = $_GET['duration'];
        if (IS_GET) {
            $mission_db = D('Mission');
            $result = $mission_db->getMInfo($jobs, $duration);
            if ($result) {
                //dump($result);
                $this->success('获取信息成功', $result);
            } else {
                $this->error('获取信息失败!');
            }
        }
    }

    //接活首页动态信息获取－登陆
    public function fetcherIndexLogin(){
        if(isset($_SESSION['loginUser'])){
            $keyword = $_GET['keyword'];
            $jobs = $_GET['jobs'];
            $duration = $_GET['duration'];
            if(IS_GET){
                $mission_db = D('Mission');
                $result = $mission_db->getMInfoLogin($keyword,$jobs, $duration);
                if ($result) {
                    $this->success('获取信息成功', $result);
                } else {
                    $this->error('获取信息失败!');
                }
            }
        }else{
            $this->error('请登陆系统',U('Login/index'));
        }
    }

    //test
    public function test($keyword,$jobs,$duration){

        $test_db = D('Mission');
        $test_result = $test_db->getMInfoLogin($keyword,$jobs,$duration);
        dump($test_result);

    }

} 